
#include "tcpServer.hpp"
#include "daemon.hpp"

#include <memory>

using namespace Server;
// 提示 运行格式
static void Usage(string proc)
{
    cout<<"Usage:\n\t" << proc <<" local_port\n\n";
}
// ./tcpserver local_port
int main(int argc,char* argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint16_t port = atoi(argv[1]);

    unique_ptr<tcpServer> tsvr(new tcpServer(port));
    tsvr->initServer();
    // tsvr->start();
//----------------------------------------------------------- 
    //让服务器变为守护进程，
    daemonSelf();
    tsvr->start();

    return 0;
}